package com.jinyi.wwdeng.ui.main.adapter

import androidx.recyclerview.widget.RecyclerView
import com.jinyi.base.utils.img.ImageUtil
import com.jinyi.lib_baseadapter.BGARecyclerViewAdapter
import com.jinyi.lib_baseadapter.BGAViewHolderHelper
import com.jinyi.wwdeng.R
import org.json.JSONObject

/**
 * JinYiTest
 * @Author wwdeng
 * @CreateTime: 2024/4/24 14:42
 * @Annotation：贷款审核推荐APP适配器
 */
class CreditAuditAppsAdapter(recyclerView: RecyclerView?) : BGARecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_apps) {
    override fun setItemChildListener(helper: BGAViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
        helper.setItemChildClickListener(R.id.btnInstall) //点击安装
    }

    override fun fillData(helper: BGAViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.tvAppName,model.optString("appName","xxx"))
        helper.setText(R.id.tvAmount,model.optString("appLoanAmount","0"))
        helper.setText(R.id.textScore,model.optString("star","0"))
        helper.setText(R.id.tvDownloadCount,model.optString("download","0"))
        val imgLogo = helper.getImageView(R.id.imgLogo)
        ImageUtil.getInstance().loadImage(mContext,imgLogo,model.optString("appLogo"),R.mipmap.pic_holder_icon)
    }
}